package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.DatabaseHelper;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 产前第一次随访第五页
 * 
 * 
 * @author sunping
 */
public class ChanQianVisitFifthActivity extends AbstractControlActivity
		implements OnClickListener {

	// 创建日期ID
	private String createDate;
	private DatabaseHelper databaseHelper = new DatabaseHelper(this);

	// 保健指导
	private int[] baoJianZhiDao = { R.id.check_jkzd_grws, R.id.check_jkzd_xl,
			R.id.check_jkzd_yy, R.id.check_jkzd_zqys, R.id.check_jkzd_xctz };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_chanqian_visit_fifth);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addRadioGroupView(R.id.rad_mdxqxsy, "梅毒血清学试验");
		addRadioGroupView(R.id.rad_hivktjc, "HIV抗体检测");
		addEditTextView(R.id.edt_bchao, "B超");
		addRadioGroupView(R.id.rad_hivktjc, "HIV抗体检测");
		addRadioGroupView(R.id.rad_ztpg, "总体评估");

		addCheckBoxView(baoJianZhiDao, "保健指导");
		addEditTextView(R.id.edt_jkzd_qt, "其它保健指导");

		addRadioGroupView(R.id.rad_zhuanzhen, "转诊");
		addEditTextView(R.id.edt_zhuanzhen_yy, "转诊原因");
		addEditTextView(R.id.edt_zhuanzhen_jgjks, "机构及科室");
		addEditTextView(R.id.edt_next_date, "下次随访日期");
		addEditTextView(R.id.edt_visit_doctor, "随访医生签名");
		addEditTextView(R.id.edt_suggestion, "指导意见");

		// // Properties文件路径
		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		Log.i(ChanQianVisitFirstActivity.class.getSimpleName(), "文件路径： "
				+ Constants.PROPERTIES_PATH + createDate + ".txt");
		controlManager.toControl();

		setEditTextListener(R.id.edt_next_date);
		setButtonListener(this, R.id.btn_complete, R.id.btn_previous);
	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮ID
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_previous:
			controlManager.toProperties();
			intent.setClass(this, ChanQianVisitForthActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			this.finish();
			break;
		case R.id.btn_complete:
			controlManager.toProperties();
			databaseHelper.updateIndexTable(createDate);
			this.toastInformation(R.string.toast_submit_info);
			intent.setClass(this, IndexActivity.class);
			startActivity(intent);
			break;
		default:
			break;
		}
	}

}
